package com.java.controller;

import java.util.Arrays;
import java.util.Map;

import com.java.pojo.Stu;
import com.java.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.java.common.utils.PageUtils;
import com.java.common.utils.R;
import springfox.documentation.annotations.ApiIgnore;


/**
 * 
 *
 * @author jl
 * @since 2020-10-13 11:31:41
 */
@ApiIgnore // swagger忽略
@RestController
@RequestMapping("/stu")
public class StuController {
    @Autowired
    private StuService stuService;

    /**
     * 带条件分页查询
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = stuService.queryPage(params);

	    return R.ok(page);
    }


    /**
     * 根据主键查询
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		Stu stu = stuService.getById(id);

        return R.ok(stu);
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    public R save(@RequestBody Stu stu){
		stuService.save(stu);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody Stu stu){
		stuService.updateById(stu);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		stuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
